<!-- modal -->
<template>
  <transition name="fade">
    <div class="modal-wrap" v-if="visible">
      <div class="modal-mask" @click="close"></div>
      <div class="modal" :style="initStyle">
        <slot name="header"></slot>
        <slot name="body"></slot>
        <slot name="footer"></slot>
      </div>
      <img v-show="showClose" class="close" src="../../static/roundclose.png" @click="close">
    </div>
  </transition>
</template>

<script>
/* eslint-disable */
export default {
  name: 'Modal',
  props: {
    visible: {
      type: Boolean,
      default: false,
      required: true
    },
    initStyle: {
      type: Object,
      default: function () {
        return {}
      }
    },
    showClose: {
      type: Boolean,
      default: false
    }
  },
  methods: {
    close () {
      this.$emit('close')
    }
  }
}
</script>

<style lang="scss" scoped>
@keyframes dialog-zoom {

    0% {
      transform: scale(0)
    }

    50% {
      transform: scale(1.1)
    }

    100% {
      transform: scale(1)
    }
}

.modal-wrap {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
}

  .modal-mask {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    background: #000000;
    opacity: 0.7;
  }

  .modal {
    position: absolute;
    top: 100px;
    min-width: 600px;
    min-height: 300px;
    height: 800px;
    max-height: 1000px;
    width: 700px;
    overflow-x: hidden;
    overflow-y: scroll;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    animation: dialog-zoom 0.4s;
    background: #fff;
    border-radius: 6px;
  }
  .close {
    position: absolute;
    top: 920px;
    width: 60px;
    height: 60px;
  }
</style>
